﻿using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using APP.HELPER.Data.Helper;
using APP.HELPER.Utils.CustomizeToolbox;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using ComboBox = System.Windows.Forms.ComboBox;

namespace Dictionary.ERP
{
    public class DIC_SHIFT
    {
        private DateTime m_BeginTime;
        private DateTime m_BeginTime1;
        private DateTime m_BeginTime2;
        private DateTime m_BreakBeginTime;
        private DateTime m_BreakEndTime;
        private string m_Description;
        private int m_DistanceMinuteAOT;
        private int m_DistanceMinuteBOT;
        private int m_EarlyMinute;
        private DateTime m_EndTime;
        private DateTime m_EndTime1;
        private DateTime m_EndTime2;
        private int m_HalfWorkMinute;
        private bool m_IsAOT;
        private bool m_IsBOT;
        private bool m_IsBreak;
        private bool m_IsBreakOvernight;
        private bool m_IsNightDutyDay;
        private bool m_IsOvernight;
        private int m_LateMinute;
        private int m_MaximumMinuteAOT;
        private int m_MaximumMinuteBOT;
        private int m_MethodCheck;
        private int m_MinimumMinuteAOT;
        private int m_MinimumMinuteBOT;
        private string m_ShiftCode;
        private string m_ShiftName;
        private double m_TotalHour;
        private int m_TotalMinute;
        private double m_WorkDay;
        private int m_WorkMinute;

        public DIC_SHIFT()
        {
            m_ShiftCode = "";
            m_ShiftName = "";
            m_BeginTime = DateTime.Now;
            m_EndTime = DateTime.Now;
            m_IsOvernight = true;
            m_BeginTime1 = DateTime.Now;
            m_BeginTime2 = DateTime.Now;
            m_EndTime1 = DateTime.Now;
            m_EndTime2 = DateTime.Now;
            m_LateMinute = 0;
            m_EarlyMinute = 0;
            m_IsBreak = true;
            m_IsBreakOvernight = true;
            m_BreakBeginTime = DateTime.Now;
            m_BreakEndTime = DateTime.Now;
            m_TotalMinute = 0;
            m_TotalHour = 0.0;
            m_HalfWorkMinute = 0;
            m_WorkMinute = 0;
            m_WorkDay = 0.0;
            m_MethodCheck = 2;
            m_IsBOT = true;
            m_IsAOT = true;
            m_MinimumMinuteBOT = 0;
            m_MaximumMinuteBOT = 0;
            m_DistanceMinuteBOT = 0;
            m_MinimumMinuteAOT = 0;
            m_MaximumMinuteAOT = 0;
            m_DistanceMinuteAOT = 0;
            m_IsNightDutyDay = true;
            m_Description = "";
        }

        public DIC_SHIFT(string ShiftCode, string ShiftName, DateTime BeginTime, DateTime EndTime, bool IsOvernight,
            DateTime BeginTime1, DateTime BeginTime2, DateTime EndTime1, DateTime EndTime2, int LateMinute,
            int EarlyMinute, bool IsBreak, bool IsBreakOvernight, DateTime BreakBeginTime, DateTime BreakEndTime,
            int TotalMinute, double TotalHour, int HalfWorkMinute, int WorkMinute, double WorkDay, int MethodCheck,
            bool IsBOT, bool IsAOT, int MinimumMinuteBOT, int MaximumMinuteBOT, int DistanceMinuteBOT,
            int MinimumMinuteAOT, int MaximumMinuteAOT, int DistanceMinuteAOT, bool IsNightDutyDay, string Description)
        {
            m_ShiftCode = ShiftCode;
            m_ShiftName = ShiftName;
            m_BeginTime = BeginTime;
            m_EndTime = EndTime;
            m_IsOvernight = IsOvernight;
            m_BeginTime1 = BeginTime1;
            m_BeginTime2 = BeginTime2;
            m_EndTime1 = EndTime1;
            m_EndTime2 = EndTime2;
            m_LateMinute = LateMinute;
            m_EarlyMinute = EarlyMinute;
            m_IsBreak = IsBreak;
            m_IsBreakOvernight = IsBreakOvernight;
            m_BreakBeginTime = BreakBeginTime;
            m_BreakEndTime = BreakEndTime;
            m_TotalMinute = TotalMinute;
            m_TotalHour = TotalHour;
            m_HalfWorkMinute = HalfWorkMinute;
            m_WorkMinute = WorkMinute;
            m_WorkDay = WorkDay;
            m_MethodCheck = MethodCheck;
            m_IsBOT = IsBOT;
            m_IsAOT = IsAOT;
            m_MinimumMinuteBOT = MinimumMinuteBOT;
            m_MaximumMinuteBOT = MaximumMinuteBOT;
            m_DistanceMinuteBOT = DistanceMinuteBOT;
            m_MinimumMinuteAOT = MinimumMinuteAOT;
            m_MaximumMinuteAOT = MaximumMinuteAOT;
            m_DistanceMinuteAOT = DistanceMinuteAOT;
            m_IsNightDutyDay = IsNightDutyDay;
            m_Description = Description;
        }

        [DisplayName("BeginTime"), Category("Column")]
        public DateTime BeginTime
        {
            get { return m_BeginTime; }
            set { m_BeginTime = value; }
        }

        [Category("Column"), DisplayName("BeginTime1")]
        public DateTime BeginTime1
        {
            get { return m_BeginTime1; }
            set { m_BeginTime1 = value; }
        }

        [Category("Column"), DisplayName("BeginTime2")]
        public DateTime BeginTime2
        {
            get { return m_BeginTime2; }
            set { m_BeginTime2 = value; }
        }

        [DisplayName("BreakBeginTime"), Category("Column")]
        public DateTime BreakBeginTime
        {
            get { return m_BreakBeginTime; }
            set { m_BreakBeginTime = value; }
        }

        [Category("Column"), DisplayName("BreakEndTime")]
        public DateTime BreakEndTime
        {
            get { return m_BreakEndTime; }
            set { m_BreakEndTime = value; }
        }

        [DisplayName("Description"), Category("Column")]
        public string Description
        {
            get { return m_Description; }
            set { m_Description = value; }
        }

        [DisplayName("DistanceMinuteAOT"), Category("Column")]
        public int DistanceMinuteAOT
        {
            get { return m_DistanceMinuteAOT; }
            set { m_DistanceMinuteAOT = value; }
        }

        [Category("Column"), DisplayName("DistanceMinuteBOT")]
        public int DistanceMinuteBOT
        {
            get { return m_DistanceMinuteBOT; }
            set { m_DistanceMinuteBOT = value; }
        }

        [Category("Column"), DisplayName("EarlyMinute")]
        public int EarlyMinute
        {
            get { return m_EarlyMinute; }
            set { m_EarlyMinute = value; }
        }

        [DisplayName("EndTime"), Category("Column")]
        public DateTime EndTime
        {
            get { return m_EndTime; }
            set { m_EndTime = value; }
        }

        [DisplayName("EndTime1"), Category("Column")]
        public DateTime EndTime1
        {
            get { return m_EndTime1; }
            set { m_EndTime1 = value; }
        }

        [Category("Column"), DisplayName("EndTime2")]
        public DateTime EndTime2
        {
            get { return m_EndTime2; }
            set { m_EndTime2 = value; }
        }

        [DisplayName("HalfWorkMinute"), Category("Column")]
        public int HalfWorkMinute
        {
            get { return m_HalfWorkMinute; }
            set { m_HalfWorkMinute = value; }
        }

        [DisplayName("IsAOT"), Category("Column")]
        public bool IsAOT
        {
            get { return m_IsAOT; }
            set { m_IsAOT = value; }
        }

        [Category("Column"), DisplayName("IsBOT")]
        public bool IsBOT
        {
            get { return m_IsBOT; }
            set { m_IsBOT = value; }
        }

        [DisplayName("IsBreak"), Category("Column")]
        public bool IsBreak
        {
            get { return m_IsBreak; }
            set { m_IsBreak = value; }
        }

        [Category("Column"), DisplayName("IsBreakOvernight")]
        public bool IsBreakOvernight
        {
            get { return m_IsBreakOvernight; }
            set { m_IsBreakOvernight = value; }
        }

        [DisplayName("IsNightDutyDay"), Category("Column")]
        public bool IsNightDutyDay
        {
            get { return m_IsNightDutyDay; }
            set { m_IsNightDutyDay = value; }
        }

        [Category("Column"), DisplayName("IsOvernight")]
        public bool IsOvernight
        {
            get { return m_IsOvernight; }
            set { m_IsOvernight = value; }
        }

        [DisplayName("LateMinute"), Category("Column")]
        public int LateMinute
        {
            get { return m_LateMinute; }
            set { m_LateMinute = value; }
        }

        [Category("Column"), DisplayName("MaximumMinuteAOT")]
        public int MaximumMinuteAOT
        {
            get { return m_MaximumMinuteAOT; }
            set { m_MaximumMinuteAOT = value; }
        }

        [Category("Column"), DisplayName("MaximumMinuteBOT")]
        public int MaximumMinuteBOT
        {
            get { return m_MaximumMinuteBOT; }
            set { m_MaximumMinuteBOT = value; }
        }

        [DisplayName("MethodCheck"), Category("Column")]
        public int MethodCheck
        {
            get { return m_MethodCheck; }
            set { m_MethodCheck = value; }
        }

        [DisplayName("MinimumMinuteAOT"), Category("Column")]
        public int MinimumMinuteAOT
        {
            get { return m_MinimumMinuteAOT; }
            set { m_MinimumMinuteAOT = value; }
        }

        [DisplayName("MinimumMinuteBOT"), Category("Column")]
        public int MinimumMinuteBOT
        {
            get { return m_MinimumMinuteBOT; }
            set { m_MinimumMinuteBOT = value; }
        }

        public string ProductName
        {
            get { return "Class DIC_SHIFT"; }
        }

        public string ProductVersion
        {
            get { return "1.0.0.0"; }
        }

        [Category("Primary Key"), DisplayName("ShiftCode")]
        public string ShiftCode
        {
            get { return m_ShiftCode; }
            set { m_ShiftCode = value; }
        }

        [Category("Column"), DisplayName("ShiftName")]
        public string ShiftName
        {
            get { return m_ShiftName; }
            set { m_ShiftName = value; }
        }

        [Category("Column"), DisplayName("TotalHour")]
        public double TotalHour
        {
            get { return m_TotalHour; }
            set { m_TotalHour = value; }
        }

        [DisplayName("TotalMinute"), Category("Column")]
        public int TotalMinute
        {
            get { return m_TotalMinute; }
            set { m_TotalMinute = value; }
        }

        [DisplayName("WorkDay"), Category("Column")]
        public double WorkDay
        {
            get { return m_WorkDay; }
            set { m_WorkDay = value; }
        }

        [Category("Column"), DisplayName("WorkMinute")]
        public int WorkMinute
        {
            get { return m_WorkMinute; }
            set { m_WorkMinute = value; }
        }

        public void AddCheckedListBox(CheckedListBoxControl checkList)
        {
            var list = new DataTable();
            list = GetList();
            foreach (DataRow row in list.Rows)
            {
                var item = new CheckedListBoxItem
                {
                    Description =
                        row["ShiftName"] + " - " + row["ShiftCode"] + " (" +
                        DateTime.Parse(row["BeginTime"].ToString()).ToString("HH:mm tt") + "->" +
                        DateTime.Parse(row["EndTime"].ToString()).ToString("HH:mm tt") + ")",
                    Value = row["ShiftCode"].ToString()
                };
                checkList.Items.Add(item);
            }
        }

        public void AddCombo(ComboBox combo)
        {
            GridCalendarControlLib.TableToComboBox(combo, GetList(), "ShiftName", "ShiftCode");
        }

        public void AddComboAll(ComboBox combo)
        {
            var list = new DataTable();
            list = GetList();
            DataRow row = list.NewRow();
            row["ShiftCode"] = "All";
            row["ShiftName"] = "Tất cả";
            list.Rows.InsertAt(row, 0);
            GridCalendarControlLib.TableToComboBox(combo, list, "ShiftName", "ShiftCode");
        }

        public void AddComboEdit(ComboBoxEdit combo)
        {
            var list = new DataTable();
            list = GetList();
            foreach (DataRow row in list.Rows)
            {
                combo.Properties.Items.Add(row["ShiftName"]);
            }
        }

        public void AddGridLookupEdit(GridLookUpEdit gridlookup)
        {
            var list = new DataTable();
            list = GetList();
            gridlookup.Properties.DataSource = list;
            gridlookup.Properties.DisplayMember = "ShiftName";
            gridlookup.Properties.ValueMember = "ShiftCode";
        }

        public string Delete()
        {
            string[] myParams = {"@ShiftCode"};
            object[] myValues = {m_ShiftCode};
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_SHIFT_Delete", myParams, myValues);
        }

        public string Delete(string ShiftCode)
        {
            string[] myParams = {"@ShiftCode"};
            object[] myValues = {ShiftCode};
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_SHIFT_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string ShiftCode)
        {
            string[] myParams = {"@ShiftCode"};
            object[] myValues = {ShiftCode};
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "DIC_SHIFT_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string ShiftCode)
        {
            string[] myParams = {"@ShiftCode"};
            object[] myValues = {ShiftCode};
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "DIC_SHIFT_Delete", myParams, myValues);
        }

        public bool Exist(string ShiftCode)
        {
            bool hasRows = false;
            string[] myParams = {"@ShiftCode"};
            object[] myValues = {ShiftCode};
            var helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("DIC_SHIFT_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public bool ExistNightDay(string ShiftCode)
        {
            bool hasRows = false;
            string[] myParams = {"@ShiftCode"};
            object[] myValues = {ShiftCode};
            var helper = new SqlHelper
            {
                CommandType = CommandType.Text
            };
            SqlDataReader reader =
                helper.ExecuteReader(
                    "select ShiftCode from DIC_SHIFT\r\n where IsNightDutyDay=1 and ShiftCode<>@ShiftCode", myParams,
                    myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(string ShiftCode)
        {
            string str = "";
            string[] myParams = {"@ShiftCode"};
            object[] myValues = {ShiftCode};
            var helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("DIC_SHIFT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    m_ShiftCode = Convert.ToString(reader["ShiftCode"]);
                    m_ShiftName = Convert.ToString(reader["ShiftName"]);
                    m_BeginTime = Convert.ToDateTime(reader["BeginTime"]);
                    m_EndTime = Convert.ToDateTime(reader["EndTime"]);
                    m_IsOvernight = Convert.ToBoolean(reader["IsOvernight"]);
                    m_BeginTime1 = Convert.ToDateTime(reader["BeginTime1"]);
                    m_BeginTime2 = Convert.ToDateTime(reader["BeginTime2"]);
                    m_EndTime1 = Convert.ToDateTime(reader["EndTime1"]);
                    m_EndTime2 = Convert.ToDateTime(reader["EndTime2"]);
                    m_LateMinute = Convert.ToInt32(reader["LateMinute"]);
                    m_EarlyMinute = Convert.ToInt32(reader["EarlyMinute"]);
                    m_IsBreak = Convert.ToBoolean(reader["IsBreak"]);
                    m_IsBreakOvernight = Convert.ToBoolean(reader["IsBreakOvernight"]);
                    m_BreakBeginTime = Convert.ToDateTime(reader["BreakBeginTime"]);
                    m_BreakEndTime = Convert.ToDateTime(reader["BreakEndTime"]);
                    m_TotalMinute = Convert.ToInt32(reader["TotalMinute"]);
                    m_TotalHour = Convert.ToDouble(reader["TotalHour"]);
                    m_HalfWorkMinute = Convert.ToInt32(reader["HalfWorkMinute"]);
                    m_WorkMinute = Convert.ToInt32(reader["WorkMinute"]);
                    m_WorkDay = Convert.ToDouble(reader["WorkDay"]);
                    m_MethodCheck = Convert.ToInt32(reader["MethodCheck"]);
                    m_IsBOT = Convert.ToBoolean(reader["IsBOT"]);
                    m_IsAOT = Convert.ToBoolean(reader["IsAOT"]);
                    m_MinimumMinuteBOT = Convert.ToInt32(reader["MinimumMinuteBOT"]);
                    m_MaximumMinuteBOT = Convert.ToInt32(reader["MaximumMinuteBOT"]);
                    m_DistanceMinuteBOT = Convert.ToInt32(reader["DistanceMinuteBOT"]);
                    m_MinimumMinuteAOT = Convert.ToInt32(reader["MinimumMinuteAOT"]);
                    m_MaximumMinuteAOT = Convert.ToInt32(reader["MaximumMinuteAOT"]);
                    m_DistanceMinuteAOT = Convert.ToInt32(reader["DistanceMinuteAOT"]);
                    m_IsNightDutyDay = Convert.ToBoolean(reader["IsNightDutyDay"]);
                    m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, string ShiftCode)
        {
            string str = "";
            string[] myParams = {"@ShiftCode"};
            object[] myValues = {ShiftCode};
            var helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "DIC_SHIFT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    m_ShiftCode = Convert.ToString(reader["ShiftCode"]);
                    m_ShiftName = Convert.ToString(reader["ShiftName"]);
                    m_BeginTime = Convert.ToDateTime(reader["BeginTime"]);
                    m_EndTime = Convert.ToDateTime(reader["EndTime"]);
                    m_IsOvernight = Convert.ToBoolean(reader["IsOvernight"]);
                    m_BeginTime1 = Convert.ToDateTime(reader["BeginTime1"]);
                    m_BeginTime2 = Convert.ToDateTime(reader["BeginTime2"]);
                    m_EndTime1 = Convert.ToDateTime(reader["EndTime1"]);
                    m_EndTime2 = Convert.ToDateTime(reader["EndTime2"]);
                    m_LateMinute = Convert.ToInt32(reader["LateMinute"]);
                    m_EarlyMinute = Convert.ToInt32(reader["EarlyMinute"]);
                    m_IsBreak = Convert.ToBoolean(reader["IsBreak"]);
                    m_IsBreakOvernight = Convert.ToBoolean(reader["IsBreakOvernight"]);
                    m_BreakBeginTime = Convert.ToDateTime(reader["BreakBeginTime"]);
                    m_BreakEndTime = Convert.ToDateTime(reader["BreakEndTime"]);
                    m_TotalMinute = Convert.ToInt32(reader["TotalMinute"]);
                    m_TotalHour = Convert.ToDouble(reader["TotalHour"]);
                    m_HalfWorkMinute = Convert.ToInt32(reader["HalfWorkMinute"]);
                    m_WorkMinute = Convert.ToInt32(reader["WorkMinute"]);
                    m_WorkDay = Convert.ToDouble(reader["WorkDay"]);
                    m_MethodCheck = Convert.ToInt32(reader["MethodCheck"]);
                    m_IsBOT = Convert.ToBoolean(reader["IsBOT"]);
                    m_IsAOT = Convert.ToBoolean(reader["IsAOT"]);
                    m_MinimumMinuteBOT = Convert.ToInt32(reader["MinimumMinuteBOT"]);
                    m_MaximumMinuteBOT = Convert.ToInt32(reader["MaximumMinuteBOT"]);
                    m_DistanceMinuteBOT = Convert.ToInt32(reader["DistanceMinuteBOT"]);
                    m_MinimumMinuteAOT = Convert.ToInt32(reader["MinimumMinuteAOT"]);
                    m_MaximumMinuteAOT = Convert.ToInt32(reader["MaximumMinuteAOT"]);
                    m_DistanceMinuteAOT = Convert.ToInt32(reader["DistanceMinuteAOT"]);
                    m_IsNightDutyDay = Convert.ToBoolean(reader["IsNightDutyDay"]);
                    m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, string ShiftCode)
        {
            string str = "";
            string[] myParams = {"@ShiftCode"};
            object[] myValues = {ShiftCode};
            var helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "DIC_SHIFT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    m_ShiftCode = Convert.ToString(reader["ShiftCode"]);
                    m_ShiftName = Convert.ToString(reader["ShiftName"]);
                    m_BeginTime = Convert.ToDateTime(reader["BeginTime"]);
                    m_EndTime = Convert.ToDateTime(reader["EndTime"]);
                    m_IsOvernight = Convert.ToBoolean(reader["IsOvernight"]);
                    m_BeginTime1 = Convert.ToDateTime(reader["BeginTime1"]);
                    m_BeginTime2 = Convert.ToDateTime(reader["BeginTime2"]);
                    m_EndTime1 = Convert.ToDateTime(reader["EndTime1"]);
                    m_EndTime2 = Convert.ToDateTime(reader["EndTime2"]);
                    m_LateMinute = Convert.ToInt32(reader["LateMinute"]);
                    m_EarlyMinute = Convert.ToInt32(reader["EarlyMinute"]);
                    m_IsBreak = Convert.ToBoolean(reader["IsBreak"]);
                    m_IsBreakOvernight = Convert.ToBoolean(reader["IsBreakOvernight"]);
                    m_BreakBeginTime = Convert.ToDateTime(reader["BreakBeginTime"]);
                    m_BreakEndTime = Convert.ToDateTime(reader["BreakEndTime"]);
                    m_TotalMinute = Convert.ToInt32(reader["TotalMinute"]);
                    m_TotalHour = Convert.ToDouble(reader["TotalHour"]);
                    m_HalfWorkMinute = Convert.ToInt32(reader["HalfWorkMinute"]);
                    m_WorkMinute = Convert.ToInt32(reader["WorkMinute"]);
                    m_WorkDay = Convert.ToDouble(reader["WorkDay"]);
                    m_MethodCheck = Convert.ToInt32(reader["MethodCheck"]);
                    m_IsBOT = Convert.ToBoolean(reader["IsBOT"]);
                    m_IsAOT = Convert.ToBoolean(reader["IsAOT"]);
                    m_MinimumMinuteBOT = Convert.ToInt32(reader["MinimumMinuteBOT"]);
                    m_MaximumMinuteBOT = Convert.ToInt32(reader["MaximumMinuteBOT"]);
                    m_DistanceMinuteBOT = Convert.ToInt32(reader["DistanceMinuteBOT"]);
                    m_MinimumMinuteAOT = Convert.ToInt32(reader["MinimumMinuteAOT"]);
                    m_MaximumMinuteAOT = Convert.ToInt32(reader["MaximumMinuteAOT"]);
                    m_DistanceMinuteAOT = Convert.ToInt32(reader["DistanceMinuteAOT"]);
                    m_IsNightDutyDay = Convert.ToBoolean(reader["IsNightDutyDay"]);
                    m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            var helper = new SqlHelper();
            return helper.ExecuteDataTable("DIC_SHIFT_GetList");
        }

        public string Insert()
        {
            string[] myParams =
            {
                "@ShiftCode", "@ShiftName", "@BeginTime", "@EndTime", "@IsOvernight", "@BeginTime1", "@BeginTime2",
                "@EndTime1", "@EndTime2", "@LateMinute", "@EarlyMinute", "@IsBreak", "@IsBreakOvernight",
                "@BreakBeginTime", "@BreakEndTime", "@TotalMinute",
                "@TotalHour", "@HalfWorkMinute", "@WorkMinute", "@WorkDay", "@MethodCheck", "@IsBOT", "@IsAOT",
                "@MinimumMinuteBOT", "@MaximumMinuteBOT", "@DistanceMinuteBOT", "@MinimumMinuteAOT", "@MaximumMinuteAOT",
                "@DistanceMinuteAOT", "@IsNightDutyDay", "@Description"
            };
            object[] myValues =
            {
                m_ShiftCode, m_ShiftName, m_BeginTime, m_EndTime, m_IsOvernight, m_BeginTime1, m_BeginTime2, m_EndTime1,
                m_EndTime2, m_LateMinute, m_EarlyMinute, m_IsBreak, m_IsBreakOvernight, m_BreakBeginTime, m_BreakEndTime,
                m_TotalMinute,
                m_TotalHour, m_HalfWorkMinute, m_WorkMinute, m_WorkDay, m_MethodCheck, m_IsBOT, m_IsAOT,
                m_MinimumMinuteBOT, m_MaximumMinuteBOT, m_DistanceMinuteBOT, m_MinimumMinuteAOT, m_MaximumMinuteAOT,
                m_DistanceMinuteAOT, m_IsNightDutyDay, m_Description
            };
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_SHIFT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams =
            {
                "@ShiftCode", "@ShiftName", "@BeginTime", "@EndTime", "@IsOvernight", "@BeginTime1", "@BeginTime2",
                "@EndTime1", "@EndTime2", "@LateMinute", "@EarlyMinute", "@IsBreak", "@IsBreakOvernight",
                "@BreakBeginTime", "@BreakEndTime", "@TotalMinute",
                "@TotalHour", "@HalfWorkMinute", "@WorkMinute", "@WorkDay", "@MethodCheck", "@IsBOT", "@IsAOT",
                "@MinimumMinuteBOT", "@MaximumMinuteBOT", "@DistanceMinuteBOT", "@MinimumMinuteAOT", "@MaximumMinuteAOT",
                "@DistanceMinuteAOT", "@IsNightDutyDay", "@Description"
            };
            object[] myValues =
            {
                m_ShiftCode, m_ShiftName, m_BeginTime, m_EndTime, m_IsOvernight, m_BeginTime1, m_BeginTime2, m_EndTime1,
                m_EndTime2, m_LateMinute, m_EarlyMinute, m_IsBreak, m_IsBreakOvernight, m_BreakBeginTime, m_BreakEndTime,
                m_TotalMinute,
                m_TotalHour, m_HalfWorkMinute, m_WorkMinute, m_WorkDay, m_MethodCheck, m_IsBOT, m_IsAOT,
                m_MinimumMinuteBOT, m_MaximumMinuteBOT, m_DistanceMinuteBOT, m_MinimumMinuteAOT, m_MaximumMinuteAOT,
                m_DistanceMinuteAOT, m_IsNightDutyDay, m_Description
            };
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "DIC_SHIFT_Insert", myParams, myValues);
        }

        public string Insert(string ShiftCode, string ShiftName, DateTime BeginTime, DateTime EndTime, bool IsOvernight,
            DateTime BeginTime1, DateTime BeginTime2, DateTime EndTime1, DateTime EndTime2, int LateMinute,
            int EarlyMinute, bool IsBreak, bool IsBreakOvernight, DateTime BreakBeginTime, DateTime BreakEndTime,
            int TotalMinute, double TotalHour, int HalfWorkMinute, int WorkMinute, double WorkDay, int MethodCheck,
            bool IsBOT, bool IsAOT, int MinimumMinuteBOT, int MaximumMinuteBOT, int DistanceMinuteBOT,
            int MinimumMinuteAOT, int MaximumMinuteAOT, int DistanceMinuteAOT, bool IsNightDutyDay, string Description)
        {
            string[] myParams =
            {
                "@ShiftCode", "@ShiftName", "@BeginTime", "@EndTime", "@IsOvernight", "@BeginTime1", "@BeginTime2",
                "@EndTime1", "@EndTime2", "@LateMinute", "@EarlyMinute", "@IsBreak", "@IsBreakOvernight",
                "@BreakBeginTime", "@BreakEndTime", "@TotalMinute",
                "@TotalHour", "@HalfWorkMinute", "@WorkMinute", "@WorkDay", "@MethodCheck", "@IsBOT", "@IsAOT",
                "@MinimumMinuteBOT", "@MaximumMinuteBOT", "@DistanceMinuteBOT", "@MinimumMinuteAOT", "@MaximumMinuteAOT",
                "@DistanceMinuteAOT", "@IsNightDutyDay", "@Description"
            };
            object[] myValues =
            {
                ShiftCode, ShiftName, BeginTime, EndTime, IsOvernight, BeginTime1, BeginTime2, EndTime1, EndTime2,
                LateMinute, EarlyMinute, IsBreak, IsBreakOvernight, BreakBeginTime, BreakEndTime, TotalMinute,
                TotalHour, HalfWorkMinute, WorkMinute, WorkDay, MethodCheck, IsBOT, IsAOT, MinimumMinuteBOT,
                MaximumMinuteBOT, DistanceMinuteBOT, MinimumMinuteAOT, MaximumMinuteAOT, DistanceMinuteAOT,
                IsNightDutyDay, Description
            };
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_SHIFT_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, string ShiftCode, string ShiftName, DateTime BeginTime,
            DateTime EndTime, bool IsOvernight, DateTime BeginTime1, DateTime BeginTime2, DateTime EndTime1,
            DateTime EndTime2, int LateMinute, int EarlyMinute, bool IsBreak, bool IsBreakOvernight,
            DateTime BreakBeginTime, DateTime BreakEndTime, int TotalMinute, double TotalHour, int HalfWorkMinute,
            int WorkMinute, double WorkDay, int MethodCheck, bool IsBOT, bool IsAOT, int MinimumMinuteBOT,
            int MaximumMinuteBOT, int DistanceMinuteBOT, int MinimumMinuteAOT, int MaximumMinuteAOT,
            int DistanceMinuteAOT, bool IsNightDutyDay, string Description)
        {
            string[] myParams =
            {
                "@ShiftCode", "@ShiftName", "@BeginTime", "@EndTime", "@IsOvernight", "@BeginTime1", "@BeginTime2",
                "@EndTime1", "@EndTime2", "@LateMinute", "@EarlyMinute", "@IsBreak", "@IsBreakOvernight",
                "@BreakBeginTime", "@BreakEndTime", "@TotalMinute",
                "@TotalHour", "@HalfWorkMinute", "@WorkMinute", "@WorkDay", "@MethodCheck", "@IsBOT", "@IsAOT",
                "@MinimumMinuteBOT", "@MaximumMinuteBOT", "@DistanceMinuteBOT", "@MinimumMinuteAOT", "@MaximumMinuteAOT",
                "@DistanceMinuteAOT", "@IsNightDutyDay", "@Description"
            };
            object[] myValues =
            {
                ShiftCode, ShiftName, BeginTime, EndTime, IsOvernight, BeginTime1, BeginTime2, EndTime1, EndTime2,
                LateMinute, EarlyMinute, IsBreak, IsBreakOvernight, BreakBeginTime, BreakEndTime, TotalMinute,
                TotalHour, HalfWorkMinute, WorkMinute, WorkDay, MethodCheck, IsBOT, IsAOT, MinimumMinuteBOT,
                MaximumMinuteBOT, DistanceMinuteBOT, MinimumMinuteAOT, MaximumMinuteAOT, DistanceMinuteAOT,
                IsNightDutyDay, Description
            };
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "DIC_SHIFT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, string ShiftCode, string ShiftName, DateTime BeginTime,
            DateTime EndTime, bool IsOvernight, DateTime BeginTime1, DateTime BeginTime2, DateTime EndTime1,
            DateTime EndTime2, int LateMinute, int EarlyMinute, bool IsBreak, bool IsBreakOvernight,
            DateTime BreakBeginTime, DateTime BreakEndTime, int TotalMinute, double TotalHour, int HalfWorkMinute,
            int WorkMinute, double WorkDay, int MethodCheck, bool IsBOT, bool IsAOT, int MinimumMinuteBOT,
            int MaximumMinuteBOT, int DistanceMinuteBOT, int MinimumMinuteAOT, int MaximumMinuteAOT,
            int DistanceMinuteAOT, bool IsNightDutyDay, string Description)
        {
            string[] myParams =
            {
                "@ShiftCode", "@ShiftName", "@BeginTime", "@EndTime", "@IsOvernight", "@BeginTime1", "@BeginTime2",
                "@EndTime1", "@EndTime2", "@LateMinute", "@EarlyMinute", "@IsBreak", "@IsBreakOvernight",
                "@BreakBeginTime", "@BreakEndTime", "@TotalMinute",
                "@TotalHour", "@HalfWorkMinute", "@WorkMinute", "@WorkDay", "@MethodCheck", "@IsBOT", "@IsAOT",
                "@MinimumMinuteBOT", "@MaximumMinuteBOT", "@DistanceMinuteBOT", "@MinimumMinuteAOT", "@MaximumMinuteAOT",
                "@DistanceMinuteAOT", "@IsNightDutyDay", "@Description"
            };
            object[] myValues =
            {
                ShiftCode, ShiftName, BeginTime, EndTime, IsOvernight, BeginTime1, BeginTime2, EndTime1, EndTime2,
                LateMinute, EarlyMinute, IsBreak, IsBreakOvernight, BreakBeginTime, BreakEndTime, TotalMinute,
                TotalHour, HalfWorkMinute, WorkMinute, WorkDay, MethodCheck, IsBOT, IsAOT, MinimumMinuteBOT,
                MaximumMinuteBOT, DistanceMinuteBOT, MinimumMinuteAOT, MaximumMinuteAOT, DistanceMinuteAOT,
                IsNightDutyDay, Description
            };
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "DIC_SHIFT_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("DIC_SHIFT", "ShiftCode", "C", 1);
        }

        public void SetData(string ShiftCode, string ShiftName, DateTime BeginTime, DateTime EndTime, bool IsOvernight,
            DateTime BeginTime1, DateTime BeginTime2, DateTime EndTime1, DateTime EndTime2, int LateMinute,
            int EarlyMinute, bool IsBreak, bool IsBreakOvernight, DateTime BreakBeginTime, DateTime BreakEndTime,
            int TotalMinute, double TotalHour, int HalfWorkMinute, int WorkMinute, double WorkDay, int MethodCheck,
            bool IsBOT, bool IsAOT, int MinimumMinuteBOT, int MaximumMinuteBOT, int DistanceMinuteBOT,
            int MinimumMinuteAOT, int MaximumMinuteAOT, int DistanceMinuteAOT, bool IsNightDutyDay, string Description)
        {
            m_ShiftCode = ShiftCode;
            m_ShiftName = ShiftName;
            m_BeginTime = BeginTime;
            m_EndTime = EndTime;
            m_IsOvernight = IsOvernight;
            m_BeginTime1 = BeginTime1;
            m_BeginTime2 = BeginTime2;
            m_EndTime1 = EndTime1;
            m_EndTime2 = EndTime2;
            m_LateMinute = LateMinute;
            m_EarlyMinute = EarlyMinute;
            m_IsBreak = IsBreak;
            m_IsBreakOvernight = IsBreakOvernight;
            m_BreakBeginTime = BreakBeginTime;
            m_BreakEndTime = BreakEndTime;
            m_TotalMinute = TotalMinute;
            m_TotalHour = TotalHour;
            m_HalfWorkMinute = HalfWorkMinute;
            m_WorkMinute = WorkMinute;
            m_WorkDay = WorkDay;
            m_MethodCheck = MethodCheck;
            m_IsBOT = IsBOT;
            m_IsAOT = IsAOT;
            m_MinimumMinuteBOT = MinimumMinuteBOT;
            m_MaximumMinuteBOT = MaximumMinuteBOT;
            m_DistanceMinuteBOT = DistanceMinuteBOT;
            m_MinimumMinuteAOT = MinimumMinuteAOT;
            m_MaximumMinuteAOT = MaximumMinuteAOT;
            m_DistanceMinuteAOT = DistanceMinuteAOT;
            m_IsNightDutyDay = IsNightDutyDay;
            m_Description = Description;
        }

        public string Update()
        {
            string[] myParams =
            {
                "@ShiftCode", "@ShiftName", "@BeginTime", "@EndTime", "@IsOvernight", "@BeginTime1", "@BeginTime2",
                "@EndTime1", "@EndTime2", "@LateMinute", "@EarlyMinute", "@IsBreak", "@IsBreakOvernight",
                "@BreakBeginTime", "@BreakEndTime", "@TotalMinute",
                "@TotalHour", "@HalfWorkMinute", "@WorkMinute", "@WorkDay", "@MethodCheck", "@IsBOT", "@IsAOT",
                "@MinimumMinuteBOT", "@MaximumMinuteBOT", "@DistanceMinuteBOT", "@MinimumMinuteAOT", "@MaximumMinuteAOT",
                "@DistanceMinuteAOT", "@IsNightDutyDay", "@Description"
            };
            object[] myValues =
            {
                m_ShiftCode, m_ShiftName, m_BeginTime, m_EndTime, m_IsOvernight, m_BeginTime1, m_BeginTime2, m_EndTime1,
                m_EndTime2, m_LateMinute, m_EarlyMinute, m_IsBreak, m_IsBreakOvernight, m_BreakBeginTime, m_BreakEndTime,
                m_TotalMinute,
                m_TotalHour, m_HalfWorkMinute, m_WorkMinute, m_WorkDay, m_MethodCheck, m_IsBOT, m_IsAOT,
                m_MinimumMinuteBOT, m_MaximumMinuteBOT, m_DistanceMinuteBOT, m_MinimumMinuteAOT, m_MaximumMinuteAOT,
                m_DistanceMinuteAOT, m_IsNightDutyDay, m_Description
            };
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_SHIFT_Update", myParams, myValues);
        }

        public string Update(string ShiftCode, string ShiftName, DateTime BeginTime, DateTime EndTime, bool IsOvernight,
            DateTime BeginTime1, DateTime BeginTime2, DateTime EndTime1, DateTime EndTime2, int LateMinute,
            int EarlyMinute, bool IsBreak, bool IsBreakOvernight, DateTime BreakBeginTime, DateTime BreakEndTime,
            int TotalMinute, double TotalHour, int HalfWorkMinute, int WorkMinute, double WorkDay, int MethodCheck,
            bool IsBOT, bool IsAOT, int MinimumMinuteBOT, int MaximumMinuteBOT, int DistanceMinuteBOT,
            int MinimumMinuteAOT, int MaximumMinuteAOT, int DistanceMinuteAOT, bool IsNightDutyDay, string Description)
        {
            string[] myParams =
            {
                "@ShiftCode", "@ShiftName", "@BeginTime", "@EndTime", "@IsOvernight", "@BeginTime1", "@BeginTime2",
                "@EndTime1", "@EndTime2", "@LateMinute", "@EarlyMinute", "@IsBreak", "@IsBreakOvernight",
                "@BreakBeginTime", "@BreakEndTime", "@TotalMinute",
                "@TotalHour", "@HalfWorkMinute", "@WorkMinute", "@WorkDay", "@MethodCheck", "@IsBOT", "@IsAOT",
                "@MinimumMinuteBOT", "@MaximumMinuteBOT", "@DistanceMinuteBOT", "@MinimumMinuteAOT", "@MaximumMinuteAOT",
                "@DistanceMinuteAOT", "@IsNightDutyDay", "@Description"
            };
            object[] myValues =
            {
                ShiftCode, ShiftName, BeginTime, EndTime, IsOvernight, BeginTime1, BeginTime2, EndTime1, EndTime2,
                LateMinute, EarlyMinute, IsBreak, IsBreakOvernight, BreakBeginTime, BreakEndTime, TotalMinute,
                TotalHour, HalfWorkMinute, WorkMinute, WorkDay, MethodCheck, IsBOT, IsAOT, MinimumMinuteBOT,
                MaximumMinuteBOT, DistanceMinuteBOT, MinimumMinuteAOT, MaximumMinuteAOT, DistanceMinuteAOT,
                IsNightDutyDay, Description
            };
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_SHIFT_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, string ShiftCode, string ShiftName, DateTime BeginTime,
            DateTime EndTime, bool IsOvernight, DateTime BeginTime1, DateTime BeginTime2, DateTime EndTime1,
            DateTime EndTime2, int LateMinute, int EarlyMinute, bool IsBreak, bool IsBreakOvernight,
            DateTime BreakBeginTime, DateTime BreakEndTime, int TotalMinute, double TotalHour, int HalfWorkMinute,
            int WorkMinute, double WorkDay, int MethodCheck, bool IsBOT, bool IsAOT, int MinimumMinuteBOT,
            int MaximumMinuteBOT, int DistanceMinuteBOT, int MinimumMinuteAOT, int MaximumMinuteAOT,
            int DistanceMinuteAOT, bool IsNightDutyDay, string Description)
        {
            string[] myParams =
            {
                "@ShiftCode", "@ShiftName", "@BeginTime", "@EndTime", "@IsOvernight", "@BeginTime1", "@BeginTime2",
                "@EndTime1", "@EndTime2", "@LateMinute", "@EarlyMinute", "@IsBreak", "@IsBreakOvernight",
                "@BreakBeginTime", "@BreakEndTime", "@TotalMinute",
                "@TotalHour", "@HalfWorkMinute", "@WorkMinute", "@WorkDay", "@MethodCheck", "@IsBOT", "@IsAOT",
                "@MinimumMinuteBOT", "@MaximumMinuteBOT", "@DistanceMinuteBOT", "@MinimumMinuteAOT", "@MaximumMinuteAOT",
                "@DistanceMinuteAOT", "@IsNightDutyDay", "@Description"
            };
            object[] myValues =
            {
                ShiftCode, ShiftName, BeginTime, EndTime, IsOvernight, BeginTime1, BeginTime2, EndTime1, EndTime2,
                LateMinute, EarlyMinute, IsBreak, IsBreakOvernight, BreakBeginTime, BreakEndTime, TotalMinute,
                TotalHour, HalfWorkMinute, WorkMinute, WorkDay, MethodCheck, IsBOT, IsAOT, MinimumMinuteBOT,
                MaximumMinuteBOT, DistanceMinuteBOT, MinimumMinuteAOT, MaximumMinuteAOT, DistanceMinuteAOT,
                IsNightDutyDay, Description
            };
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "DIC_SHIFT_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, string ShiftCode, string ShiftName, DateTime BeginTime,
            DateTime EndTime, bool IsOvernight, DateTime BeginTime1, DateTime BeginTime2, DateTime EndTime1,
            DateTime EndTime2, int LateMinute, int EarlyMinute, bool IsBreak, bool IsBreakOvernight,
            DateTime BreakBeginTime, DateTime BreakEndTime, int TotalMinute, double TotalHour, int HalfWorkMinute,
            int WorkMinute, double WorkDay, int MethodCheck, bool IsBOT, bool IsAOT, int MinimumMinuteBOT,
            int MaximumMinuteBOT, int DistanceMinuteBOT, int MinimumMinuteAOT, int MaximumMinuteAOT,
            int DistanceMinuteAOT, bool IsNightDutyDay, string Description)
        {
            string[] myParams =
            {
                "@ShiftCode", "@ShiftName", "@BeginTime", "@EndTime", "@IsOvernight", "@BeginTime1", "@BeginTime2",
                "@EndTime1", "@EndTime2", "@LateMinute", "@EarlyMinute", "@IsBreak", "@IsBreakOvernight",
                "@BreakBeginTime", "@BreakEndTime", "@TotalMinute",
                "@TotalHour", "@HalfWorkMinute", "@WorkMinute", "@WorkDay", "@MethodCheck", "@IsBOT", "@IsAOT",
                "@MinimumMinuteBOT", "@MaximumMinuteBOT", "@DistanceMinuteBOT", "@MinimumMinuteAOT", "@MaximumMinuteAOT",
                "@DistanceMinuteAOT", "@IsNightDutyDay", "@Description"
            };
            object[] myValues =
            {
                ShiftCode, ShiftName, BeginTime, EndTime, IsOvernight, BeginTime1, BeginTime2, EndTime1, EndTime2,
                LateMinute, EarlyMinute, IsBreak, IsBreakOvernight, BreakBeginTime, BreakEndTime, TotalMinute,
                TotalHour, HalfWorkMinute, WorkMinute, WorkDay, MethodCheck, IsBOT, IsAOT, MinimumMinuteBOT,
                MaximumMinuteBOT, DistanceMinuteBOT, MinimumMinuteAOT, MaximumMinuteAOT, DistanceMinuteAOT,
                IsNightDutyDay, Description
            };
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "DIC_SHIFT_Update", myParams, myValues);
        }
    }
}